package com.lmqb.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lmqb.bean.SysConfig;
import com.lmqb.constant.Redis;
import com.lmqb.service.SysBaseService;
import com.lmqb.util.RedisUtil;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;


@Controller
public class RedisController {

    @Autowired
    private SysBaseService sysBaseService;
    
    
	@RequestMapping("redisController")
	public String redistest(){
		List<SysConfig> list = sysBaseService.selectAllCfg();
		String groub="params_config";
		String key[]=new String[list.size()];
		String value[]=new String[list.size()];
		//实例化一个jedis对象，连接到指定的服务器，指定连接端口号
        Jedis jedis = null;
        jedis=RedisUtil.initPool().getResource();
        for(int i=0;i<list.size();i++){
        key[i]=list.get(i).getPmCate()+"_"+list.get(i).getPmKey();
        value[i]=list.get(i).getPmValue();
        jedis.hset(groub,key[i],value[i]);
        System.out.println(key[i]+"---->"+jedis.hget(groub, key[i]));
        }
        //关闭连接
        jedis.close();
		return "index";
	}
	
	
}
